
<div style="height:50%; overflow:hidden;">

    <fieldset style="height:100%;">
        <legend>已绑定节点</legend>

        <div id="layout-01" style="height:100%; overflow:hidden;">
            <#--<div class="bjui-pageContent">-->
            <#include "include/layout1.ftl" />
        </div>
    </fieldset>

</div>
<div class="bjui-pageHeader">
    <#--<form id="pagerForm" data-toggle="ajaxsearch" action="layout/layout-02.html" method="post">-->
        <div class="bjui-searchBar">
            <button type="button" class="btn-default" onclick="bindNode();">∧增加</button>&nbsp;
            <button type="button" class="btn-red" onclick="unbindNode();">∨删除</button>&nbsp;
        </div>
    <#--</form>-->
</div>
<div style="height:50%; overflow:hidden;">
    <fieldset style="height:100%;">
        <legend>可选节点</legend>
        <div id="layout-02" style="height:88%; overflow:auto;">
            <#--<#include "include/layout2.ftl" />-->
        </div>
    </fieldset>
</div>
<script>

    $.ajax({
        url: "/admin/agent/listunbind"
        , type: "POST"
        , data: "groupType="+currentGroupType+"&random="+new Date().getTime()
        , success: function( data, textStatus, jqXHR ){
            $('#layout-02').html(data);
        }
    });
    function bindNode()
    {
        var unbindIds = $('#unbindIds').val();
        if(unbindIds.length>0)
        {
            $.ajax({
                url: "/admin/agent/node/bind"
                , type: "POST"
                , data: "groupType="+currentGroupType+"&agentId=${(agentId)!}&unbindIds="+unbindIds
                , success: function( data, textStatus, jqXHR ){
//                    $('#layout-02').html(data);
                    refreshDiv();
                }
            });
        }
    }
    function unbindNode()
    {
        var bindIds = $('#bindIds').val();
        if(bindIds.length>0)
        {
            $.ajax({
                url: "/admin/agent/node/unbind"
                , type: "POST"
                , data: "groupType="+currentGroupType+"&bindIds="+bindIds
                , success: function( data, textStatus, jqXHR ){
//                    $('#layout-02').html(data);
                    refreshDiv();
                }
            });
        }
    }

    function refreshDiv()
    {
        $.ajax({
            url: "/admin/agent/listbind?agentId=${(agentId)!}"
            , type: "POST"
            , data: "groupType="+currentGroupType+"&random="+new Date().getTime()
            , success: function( data, textStatus, jqXHR ){

                $('#'+currentGroupType+'_TAB').html(data);
//                $('#dbServerTab').html(data);
            }
        });

        $.ajax({
            url: "/admin/agent/listunbind"
            , type: "POST"
            , data: "groupType="+currentGroupType+"&random="+new Date().getTime()
            , success: function( data, textStatus, jqXHR ){
                $('#layout-02').html(data);
            }
        });
    }
</script>